package xdpm.nhom16.DAO;

import xdpm.nhom16.DTO.TuKhoaPhuongDTO;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;

public class TuKhoaPhuongDAO extends AbstractTuKhoaDAO<TuKhoaPhuongDTO> {

	protected static final String COLUMN_PARENT = "MaPhuong";
	protected static final String COLUMN_TUKHOA = "TuKhoaPhuong";
	protected static final String COLUMN_ID = "MaTuKhoaPhuong";
	protected static final String[] NAME_COLUMNS = new String[] { COLUMN_ID, COLUMN_TUKHOA, COLUMN_PARENT };
	protected static final String TABLE_NAME = "TUKHOAPHUONG";

	public TuKhoaPhuongDAO(SQLiteDatabase db) {
		super(db);
		// TODO Auto-generated constructor stub
	}

	@Override
	protected String getTableName() {
		return TABLE_NAME;
	}

	@Override
	protected String getNameColumnId() {
		return COLUMN_ID;
	}

	@Override
	protected String[] getNameColumns() {
		return NAME_COLUMNS;
	}

	@Override
	protected TuKhoaPhuongDTO cusorToDTO(Cursor cursor) {
		int id = cursor.getInt(0);
		TuKhoaPhuongDTO dto = new TuKhoaPhuongDTO();
		dto.setMaTuKhoaPhuong(id);
		if (!cursor.isNull(1))
			dto.setTuKhoaPhuong(cursor.getString(1));
		if (!cursor.isNull(2))
			dto.setMaPhuong(cursor.getInt(2));
		return dto;
	}

	@Override
	protected String getNameColumnTuKhoa() {
		return COLUMN_TUKHOA;
	}

	@Override
	protected String getNameColumnRefIdParent() {
		// TODO Auto-generated method stub
		return COLUMN_PARENT;
	}
}
